package com.heima.comment.controller;

import com.heima.comment.service.CommentService;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.mango.dtos.CommentDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment/")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 发布评论
     * @param dto
     * @return
     */
    @PostMapping("save")
    public ResponseResult saveComment(@RequestBody CommentDto dto){
        return commentService.saveComment(dto);
    }

    /**
     * 查询评论列表
     * @return
     */
    @PostMapping("load")
    public ResponseResult loadComment(@RequestBody CommentDto dto){return commentService.loadComment(dto);}

    /**
     * 点赞评论
     * @param dto
     * @return
     */
    @PostMapping("like")
    public  ResponseResult likeComment(@RequestBody CommentDto dto){return  commentService.likeComment(dto);}
}
